<?php

/**
 * @author Alexandr McArrow
 * @email alex.mcarrow@gmail.com
 * @company Macrox Lab
 * @copyright Macrox Lab by Alexandr McArrow 2008
 * @project MySQLUNI
 * @name MySQL uniconnect
 */

function MySQL_uni_connect($dbhost,$dbname,$dbuser,$dbpasswd,$dbchar,$url)
{
	
$MSUC['MYSQL'] = false;

if(@mysql_connect($dbhost,$dbuser,$dbpasswd))
{
    if(@mysql_select_db($dbname))
    {
        if(@mysql_query("SET NAMES ".$dbchar))
        {
            $MSUC['MYSQL'] = true;
        } else
        {
            $MSUC['MYSQL'] = "SET CHARSET";
        }
    } else
    {
        $MSUC['MYSQL'] = "SELECT DB";
    }
} else
{
    $MSUC['MYSQL'] = "CONNECT TO MYSQL-SERVER";
}

if($MSUC['MYSQL'] !== true)
{
    echo '<html><style type="text/css">.Macrox {font-family: Tahoma;font-size: 64px;font-weight: bold;color: #CCCCCC;text-decoration: none;}.error_code {font-family: Arial, Helvetica, sans-serif;font-size: 12px;font-weight: normal;color: #FFFFFF;text-decoration: none;}.error_code a{color: #999999;text-decoration: none;font-weight: bold;font-size: 14px;}body {background-color: #000000;}</style><body><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle"><table width="400" border="0" cellspacing="5" cellpadding="5"><tr><td align="center" valign="middle" class="Macrox">Macrox Lab</td></tr><tr><td></td></tr><tr><td align="center" class="error_code"><b>MYSQL ERROR ('.$MSUC['MYSQL'].')</b><br>Service is temporarily not available.<br><a href="'.$url.'">Try to repeat the request later</a><br>Administration has been informed. </td></tr></table></td></tr></table></body></html>';
    die;
}
else
{
	return true;
}

}

?>